/*
 * Created on Jun 10, 2005
 */
package org.vectrics.common.db;

import java.sql.ResultSet;

import org.vectrics.SystemException;

/**
 * @author MMoore
 */
public class SurrogateKeyJdbcTarget implements JdbcTarget {
	private String code = null;
	private Long nextId = null;
	private Long startId = null;
	
	
	
	/**
	 * 
	 */
	public SurrogateKeyJdbcTarget(String code) {
		super();
		this.code = code;
	}

	public Long getNextId() {
		return nextId;
	}

	public Long getStartId() {
		return startId;
	}
	
	public void processResults(ResultSet results) throws ProcessException {
		try {
			if (results.next()) {
				nextId = new Long(results.getLong("srgt_ky_id"));
				startId = new Long(results.getLong("srgt_ky_strt_id"));
				
			} 
		}
		catch (java.sql.SQLException se) {
			throw new SystemException(
					"getUsersWithRole() - SQL Exception while processing results list", se);
		}
	}

	public String getQuery() {
		String sql = "select srgt_ky_id, srgt_ky_strt_id from srgt_key where srgt_ky_cd='"
			+ code + "'";
		return(sql);
	}

}
